-- worker
-- created by panyl
-- 遗迹建筑功能-挖掘工

return {
    canDevelop = function(id)
        -- 所有宠物
        local total = 0;
        local pets = ME.user.pets;
        for _, pet in pairs(pets) do
            total = total + pet:getRank();
        end
        -- 挖掘功能不能超过星阶限制
        local needCount = FormulaM.invoke("CALC_RELIC_WORKER_RANK_LIMIT", SkyRelicFunctionM.getLevel(id) + 1);
        if needCount > total then
            return false;
        end
        return true;
    end,

    -- 星阶限制
    limitDevelopDesc = function(id)
        local total = 0;
        local pets = ME.user.pets;
        for _, pet in pairs(pets) do
            total = total + pet:getRank();
        end
        local needCount = FormulaM.invoke("CALC_RELIC_WORKER_RANK_LIMIT", SkyRelicFunctionM.getLevel(id) + 1);
        return string.format(getLocStr("relic_function_limit_tip"), needCount, total);
    end,

    -- 获取描述
    getDesc = function(desc)
        -- 20s的速度
        local countPerHour = ME.user:queryAttrib("scrap_speed") * 3600 / SkyRelicM.getGatherUnitTime();
        desc = string.gsub(desc, "{0}", tostring(countPerHour));
        return desc;
    end,
};
